import React, {createContext, useReducer} from "react";
import reducer from "./reducer";

const initState: any = {
    assemblyList: [],
    curSelectedAssembly: [],
};


export const EditContext  = createContext({breadArr:initState});

function EditStore(props: any){
    const [state, dispatch] = useReducer(reducer, initState);
    return (
        <EditContext.Provider value={{state, dispatch}}>
            {props.children}
        </EditContext.Provider>
    );
}

// 自定义state的hooks
export const useEditStore = () => React.useContext(EditContext);

export default EditStore;